package com.va.yahooweather.entity;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

public class YLocation {
    private String city = "";
    private String region = "";
    private String country = "";

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getRegion() {
        return region;
    }

    public void setRegion(String region) {
        this.region = region;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        
        if (this == obj) {
            return true;
        }
        
        YLocation target = (YLocation) obj;
        return new EqualsBuilder()
            .append(getCity(), target.getCity())
            .append(getCountry(), target.getCountry())
            .append(getRegion(), target.getRegion())
            .isEquals();
    }

    @Override
    public int hashCode() {
        HashCodeBuilder h = new HashCodeBuilder(3, 41);
        h.append(getCity());
        h.append(getCountry());
        h.append(getRegion());
        return h.hashCode();
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        
        sb.append(getCity()).append(", ")
            .append(getRegion()).append(", ")
            .append(getCountry()).append("\n");
        
        return sb.toString();
    }

}
